define(function(require, exports, module) {

    var axios = require('lib/axios/index.js');

    var ShowCode = require("components/show-code/index.js");

    var layer = require('components/layer/index.js');


    window.vueApp = new Vue({
        el: '#app',
        data: {
            tableList: [

            ],
            form: {
                Title: '',
                DmlKey: '',
                DataFlag: ''
            },
            enums: {
                DataFlag: []
            }
        },
        mounted: function() {

            var thisVue = this;
            thisVue.tableSearch();

            var url = baseSiteUrl + "/USER/EnumConvert2";
            axios.get(url)
                .then(function(response) {
                    thisVue.enums.DataFlag = response.data;
                });


        },
        methods: {

            tableSearch: function() {
                var thisVue = this;
                var tools = require('lib/tools.js');
                var queryString = tools.getQueryString.call(thisVue.form);


                var url = baseSiteUrl + "SysDml/ValidList";
                if (queryString != "") {
                    url = url + "?" + queryString;
                }

                axios.get(url)
                    .then(function(response) {
                        thisVue.tableList = response.data;
                        console.log(response.data);
                        console.log(response.status);
                        console.log(response.statusText);
                        console.log(response.headers);
                        console.log(response.config);
                    });
            },

            handleQuickSaveClick: function(row) {

                var url = baseSiteUrl + "SysDml/SaveOrUpdate"
                $.ajax({
                    type: 'POST',
                    url: url,
                    dataType: 'json',
                    data: row,
                    success: function(res) {
                        toastr.success('操作成功');
                        // if (res.success) {
                        //     toastr.success('操作成功');
                        // }
                        // else {
                        //     toastr.error(res.msg);
                        // }
                    }
                })
            },
            handleAddClick: function(row) {
                layer.open({
                    type: 2,
                    area: ["90%", '90%'],
                    content: 'dmlEdit.html?id=0'
                });
            },
            handleEditClick: function(row) {
                layer.open({
                    type: 2,
                    area: ["90%", '90%'],
                    content: 'dmlEdit.html?id=' + row.Id
                });
            }

        }

    });

});